package com.blacksee.bluetoothpoker.network.messages;

import com.blacksee.bluetoothpoker.logic.net.mypapit.java.StringTokenizer;

public class BetMessage implements NetMessage{
	
	public static final int ACTION_BET = 1;
	public static final int ACTION_CALL = 2;
	public static final int ACTION_FOLD = 3;
	public static final int ACTION_CHECK = 4;
	
	private int senderID;
	private int type;
	private int amount;
	private boolean isAllIn;
	
	public BetMessage(){
	}
	
	
	
	public BetMessage(int senderID, int messageType){
		this(senderID, messageType, 0, false);
	}
	
	public BetMessage(int senderID, int messageType, int amount, boolean isAllIn){
		this.senderID = senderID;
		this.type = messageType;
		this.amount = amount;
		this.isAllIn = isAllIn;
	}
	
	public int getSenderID() {
		return senderID;
	}

	public int getType() {
		return type;
	}
	
	public int getAmount() {
		return amount;
	}
	
	public boolean IsAllIn() {
		return isAllIn;
	}

	public void parseParameters(String message) {
		StringTokenizer tok = new StringTokenizer(message);
		String messageHead = tok.next().toString();
		
		if (this.type == 1) // "ACTION_BET"
		{
			//msg format: "ACTION_BET*value"
			int value = Integer.parseInt(tok.next().toString());
			this.amount = value;
		}
			
		else if(this.type == 2)   // "ACTION_CALL") //2
		{
			
		}
		else if(this.type == 3 )   //"ACTION_FOLD") //3
		{
			
		}
		else if(this.type == 4) // "ACTION_CHECK") //4
		{
			
		}
	}



	public String GetMessageString() {
		// return the text representation of the message
		String text = null;
		
		switch(this.type){
		case 1:
			text = "ACTION_BET*" + this.amount;
			break;
		case 2:
			text = "ACTION_CALL" ;
			break;
		case 3:
			text = "ACTION_FOLD" ;
			break;
		case 4:
			text = "ACTION_CHECK" ;
			break;
		}
		
		return text;
	}
	
	
}
